package j_composite.a_design_pattern;

/**
 * Created by wug on 2016/7/14 0014.
 */
public class MainTest {
    public static void main(String[] args) {
        /**
         * 组合模式非常像树状结构，所以直接用区域来解释会很清楚
         */
        Component province = new Composite("浙江省");
        Component hz = new Composite("杭州市");
        Component xhq = new Leaf("西湖区");
        Component scq = new Leaf("上城区");
        Component xcq = new Leaf("下城区");
        Component bjq = new Leaf("滨江区");
        Component nb = new Composite("宁波市");
        Component sx = new Composite("绍兴市");
        hz.add(xhq).add(scq).add(xcq).add(bjq);
        province.add(nb).add(hz).add(sx);
        /**
         * 有点像递归的方式去遍历区域树
         */
        province.operation();
    }
}
